cmake_minimum_required(VERSION 3.0)

project(kbox C)

set(CMAKE_C_STANDARD 99)
set(CMAKE_BUILD_TYPE Debug)

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")

# add_compile_options(-g)  

# 包含 include 目录
include_directories(./include)
include_directories(../NtyCo/core)

# 查找 src 目录下的所有源文件
file(GLOB SOURCES "src/*.c")

# 指定库文件目录
link_directories(../NtyCo)

# 添加可执行文件
add_executable(kbox ${SOURCES})

add_subdirectory(./test)

# 确保链接静态库时不丢失未解析的符号
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--no-relax")

# 显式指定静态库路径，确保正确链接
target_link_libraries(kbox PRIVATE ${CMAKE_SOURCE_DIR}/../NtyCo/libntyco.a -pthread -ldl)

# 自定义 clean-all 目标
add_custom_target(clean-all 
    COMMAND ${CMAKE_COMMAND} -E remove_directory ${CMAKE_BINARY_DIR}
    COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}
)


